package com.chen.pojo.bean;

import cn.hutool.core.date.DateUtil;
import com.chen.pojo.Permission;
import com.chen.pojo.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.ObjectUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Set;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserInfo implements Serializable {
    private Integer id;
    private String username;
    private String nick;
    private int age;
    private String sex;
    private String address;
    private String avatar;
    private String token;

    private String openid;


    private String regtime;

    private String introduce;

    private int role;
    private int points;
    private List<Integer> roles;
    private Set<Permission> permissions;

    public UserInfo(User user) {
        this.id = user.getId();
        this.age = user.getAge();
        this.sex = user.getSex();
        this.address = user.getAddress();
        this.token = user.getToken();
        this.username = user.getUsername();
        this.nick = user.getNick();
        this.regtime = user.getRegtime();
        this.role=user.getRole();
        this.openid = user.getOpenId();
        this.points=user.getPoints();
        this.roles=user.getRoles();
        this.permissions=user.getPermissions();



        this.avatar = user.getAvatar() != null ? user.getAvatar() : "https://img2.baidu.com/it/u=2285567582,1185119578&fm=26&fmt=auto";
        this.introduce = user.getIntroduce() != null ? user.getIntroduce() : "介绍一下自己吧";

    }


}
